package com.example.wzh.service;

import com.example.wzh.entity.UserEntity;
import com.example.wzh.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component
@Service
public class UserService {
    @Autowired
    UserRepository userRepository;

    public boolean isValid(String username, String password) {
        UserEntity user = userRepository.findByUsername(username);
        if (user != null && user.getPassword().equals(password)) {
            System.out.println(user.toString());
            return true;
        } else {
            System.err.println("user is null");
            return false;
        }
    }
}
